// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
    env: "yiliaojiufeng-6gt0kj1l1df8b7b7",
    traceUser: true,
})

// 云函数入口函数

const db = cloud.database()
exports.main = async (event, context) => {
    const wxContext = cloud.getWXContext()

    var result = await db.collection('user_Star').where({
            _openid: wxContext.OPENID
    }).get()

    console.log(result.data)

    var i = 0
    var myStar = []
    var temp ={}

    for (i = 0;i<result.data.length;i++) {
        temp = await db.collection('news_article').where({
                _id: result.data[i].newsId
        }).get()
        console.log(temp)
        myStar.push(temp.data[0])
    }

    return myStar


}